package com.kang.controller;

import com.kang.pojo.Users;
import com.kang.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author 吃三明治派对中的康康
 * @Date 2022/4/30 19:19
 * @Version 1.0
 */
@Controller
public class EnrollController {

    @Autowired
    UsersService usersService;

    @RequestMapping("/toReg")
    public String toEnroll(){
        return "reg";
    }

    @PostMapping("/reg")
    public String enroll(Model model, Users user, String repassword){

        if(usersService.regUser(user,repassword) == 0){
            model.addAttribute("errMsg","请仔细检查输入！");
            return "reg";
        }
        return "redirect:toLogin";
    }

}
